namespace Demo.Services;

using Demo.DbContext;

public class UserService
{
    public UserService()
    {
        _userRepository = new();
    }
    private readonly UserRepository? _userRepository = null;
    public bool Register(User user)
    {
        if (string.IsNullOrWhiteSpace(user.Email))
        {
            return false;
        }
        int 添加数据行数 =  _userRepository.Add(user);
        return 添加数据行数 > 0;
    }
    // public bool Login(User user)
    // {

    // }
    public User? GetByID(int id)
    {
        return _userRepository?.GetByID(id);
    }
    public bool ExistByEmail(string email)
    {
        return _userRepository?.GetByEmail(email) != null;
    }
    public List<User> Exproler()
    {
        return _userRepository.Exproler();
    }
}